<?php
class Hora
{
	var $hora="";
	
	function __construct()
	{
		switch(func_num_args())
		{
			case 0: $this->set();break;
			
			case 1:	if(trim(func_get_arg(0)) =="")return;
					$this->set( func_get_arg( 0 ) );
					break;
		}
	}
	
	function set(){
		switch(func_num_args())
		{
			case 0: $this->set(date("H:i:s"));return;
			
			case 1:	if(trim(func_get_arg(0)) =="")return;
					$this->hora=func_get_arg(0);
					return;
		}
	}
	function get(){
		return $this->hora;
	}
	function toString(){
		return substr ($this->get(),0,5);
	}
	function getHora(){
		$array=explode(":",$this->hora);
		return $array[0];
	}
	function getMinutos(){
		$array=explode(":",$this->hora);
		return $array[1];
	}
	function getSegundos(){
		$array=explode(":",$this->hora);
		return $array[2];
	}
	
	function getMktime($ha,$da){
		return mktime($ha->getHora(),$ha->getMinutos(),0,$da->getMes(),$da->getDia(),$da->getAno());
	}
	function cmp(){
		switch(func_num_args())
		{
			case 2: $h1=new Hora(func_get_arg(0));
					$h2=new Hora(func_get_arg(1));
					$f1=new Fecha(date("Y-m-d"));
					$f2=new Fecha(date("Y-m-d"));
				break;
			case 4:	$h1=new Hora(func_get_arg(0));
					$h2=new Hora(func_get_arg(2));
					$f1=new Fecha(func_get_arg(1));
					$f2=new Fecha(func_get_arg(3));
				break;
		}
		
		$uno=Hora::getMktime($h1,$f1);
		$dos=Hora::getMktime($h2,$f2);
		
		if($uno>$dos)
			return -1;
		if($uno<$dos)
			return 1;
		return 0;
	}
}
?>
